package edu.lfsfxy.myschool.controller;

import edu.lfsfxy.myschool.entity.Course;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/param")
public class ParamController {
    @RequestMapping("/base")
    public String param1(Model model){
        int i=10;
        model.addAttribute("i",i);//springMVC将数据放到request域对象中
        model.addAttribute("str","hello");
        Course course=new Course();
        course.setCno(1002);
        course.setCname("html");
        course.setClassHour(64);
        model.addAttribute("c",course);
        Course course2 =new Course();
        course2.setCno(1002);
        course2.setCname("html");
        course2.setClassHour(64);
        List<Course> list=new ArrayList<>();
        list.add(course);
        list.add(course2);
        model.addAttribute("list",list);
        return "param";
    }
    @RequestMapping("/ifTest")
    public String ifTest(Model model){
        Course course=new Course();
        course.setCno(1002);
        course.setCname("html");
        course.setClassHour(64);
        model.addAttribute("c",course);
        return "ifTest";
    }
}
